<?php
declare (strict_types = 1);

namespace app\middleware\api\v1;

use Closure;

class AuthMiddleware
{
    /**
     * 处理请求
     *
     * @param $request
     * @param Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        $user = auth('api')->userOrFail();
        $request->withMiddleware(['user' => $user]);
        return $next($request);
    }
}
